// 校验规则
function Rule(object) {
  var obj = object
  const tipMsg = '不能为空'

  this.promotionStartDateRules = function() {
    obj.rules.promotionStartDate = [
      { required: true, message: tipMsg, trigger: 'blur' },
      { required: true, message: tipMsg, trigger: 'change' },
      { validator: obj.validate.promotionStartDateCheck, trigger: 'blur' },
      { validator: obj.validate.promotionStartDateCheck, trigger: 'change' }
    ]
  }

  this.promotionEndDateRules = function() {
    obj.rules.promotionEndDate = [
      { required: true, message: tipMsg, trigger: 'blur' },
      { required: true, message: tipMsg, trigger: 'change' },
      { validator: obj.validate.promotionEndDateCheck, trigger: 'blur' },
      { validator: obj.validate.promotionEndDateCheck, trigger: 'change' }
    ]
  }

  this.scheduleIdRules = function() {
    obj.rules.scheduleId = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.deptNbrRules = function() {
    obj.rules.deptNbr = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.buyerIdRules = function() {
    obj.rules.buyerId = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.cateIdRules = function() {
    obj.rules.cateId = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.deptNbrRules = function() {
    obj.rules.deptNbr = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.onlineUpcNbrRules = function() {
    obj.rules.onlineUpcNbr = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.onlineItemNameRules = function() {
    // obj.rules.onlineItemName = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.promotionPriceRules = function() {
    // obj.rules.promotionPrice = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.buyLimitedRules = function() {
    // obj.rules.buyLimited = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.sendStoreRules = function() {
    obj.rules.sendStore = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.omitSendStoreRules = function() {
    // obj.rules.omitSendStore = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.listTypeRules = function() {
    // obj.rules.listType = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  this.optionTypeRules = function() {
    obj.rules.optionType = [{ required: true, message: tipMsg, trigger: 'blur' }, { required: true, message: tipMsg, trigger: 'change' }]
  }

  // 初始化校验规则
  this.initRules = function() {
    for (var key in this) {
      // console.log(key)
      if (key === 'initRules') {
        continue
      }
      if (typeof (this[key]) === 'function') {
        this[key]()
      }
    }
  }
}
export default Rule
